using System;
using System.Text;
using System.Runtime.InteropServices;

namespace DisplaySC
{
    internal class IniFileHelper
    {
        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);

        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);


        public static void WriteValue(string section, string key, object value)
        {
            WritePrivateProfileString(section, key, value.ToString(), IniPath);
        }

        public static string ReadValue(string section, string key)
        {
            StringBuilder temp = new StringBuilder(255);
            GetPrivateProfileString(section, key, "", temp, 255, IniPath);
            
            return temp.ToString();
        }

        public static string IniPath { get; set; }
    }
}
